import json

import requests


def __query_json__():
    # URL 地址
    url = 'http://10.10.80.215:9089/api/quota/staticsByMonth'

    headers = {"combine-token": "fc46a483-c4a4-41a9-a8a7-2e45503a61de,89cdbbd8-2ca2-4991-a253-94d6f16fbd8c"}
    data = {
        "timeGranularity": "monthly",
        "queryTime": ""
    }

    # 发送 POST 请求
    response = requests.post(url, headers=headers, json=data)

    # 打印响应的内容
    if response.status_code == 200:
        response_data = json.loads(response.text)
        # 格式化JSON输出
        formatted_response_data = json.dumps(response_data, indent=4, ensure_ascii=False)
        # 将响应结果写入新文件
        # with open('/gs/data/response/事件/response.json', 'w',
        #           encoding='utf-8') as outfile:
        #     outfile.write(formatted_response_data)
        print(formatted_response_data)
    else:
        print(f'请求失败，状态码：{response.status_code}')


if __name__ == '__main__':
    __query_json__()


